//
//  RHBatteryClusterChartView.m
//  RuiHeAppApp
//
//  Created by Yan Chen on 2023/10/26.
//

#import "RHBatteryClusterChartView.h"
#import "DevChartModel.h"
#import "QMUILabel+LHAdd.h"
#import "DeviceChartFieldModel.h"
#import "DeviceChartItemView.h"
#import "NSString+LenWid.h"

#import "RHCellRealDataModel.h"

#import "RHMaskView.h"
#import "RHCellMarkerView.h"

@interface RHBatteryClusterChartView()<ChartViewDelegate,ChartAxisValueFormatter>
@property (nonatomic ,copy) NSArray *colorList;

/// 图表
@property (nonatomic, strong) LineChartView *lineChartView;
//气泡
@property (nonatomic, strong) RHCellMarkerView *maskView;

//左边Y轴单位
@property (nonatomic, strong) QMUILabel *leftUnitLab;
//右边Y轴单位
@property (nonatomic, strong) QMUILabel *rightUnitLab;

@property (nonatomic ,assign) NSInteger type;

@property (nonatomic, strong) UIView *scrollBgView;

@property (nonatomic, strong) UIScrollView *scroll;

@property (nonatomic, strong) UIView *contentView;

@property (nonatomic, assign) NSInteger selectIndex;

@property (nonatomic, strong) NSMutableArray *itemsArray;

@property (nonatomic, strong) NSMutableArray *pointViewArr;

@property (nonatomic, strong) NSMutableArray *unitArr;

@property (nonatomic, assign) BOOL isLandscape;//是否横屏
@end
@implementation RHBatteryClusterChartView

- (instancetype)initWithFrame:(CGRect)frame isLandscape:(BOOL)type;{
    self = [super initWithFrame:frame];
    if (self) {
        self.colorList = @[@"#8956F8",@"#FDD015",@"#10E2FF",@"#58C373",@"#FB8480"];
        self.isLandscape = type;
        [self setupUI];
       
    }
    return self;
}



- (void)setupUI{
    
    kWeakSelf;
    
    [self addSubview:self.lineChartView];
    
    //添加单位
    QMUILabel *leftUnitLab = [[QMUILabel alloc]init];
    leftUnitLab.textColor = UIColor.lightGrayColor;
    leftUnitLab.font = [UIFont systemFontOfSize:13];
    [self addSubview:leftUnitLab];
    self.leftUnitLab = leftUnitLab;
    
    QMUILabel *rightUnitLab = [[QMUILabel alloc]init];
    rightUnitLab.textColor = UIColor.lightGrayColor;
    rightUnitLab.font = [UIFont systemFontOfSize:13];
    [self addSubview:rightUnitLab];
    self.rightUnitLab = rightUnitLab;
    
    [leftUnitLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_offset(10);
        
    }];
    
    [rightUnitLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_offset(-10);
        make.centerY.equalTo(leftUnitLab);
    }];
    
    
    [self.lineChartView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(5);
        make.right.mas_offset(-5);
        make.top.equalTo(leftUnitLab.mas_bottom).offset(10);
        if(weakSelf.isLandscape){
            
        }else{
            make.height.mas_equalTo(kUI_WINDOW_W*0.5);
        }
       
       
    }];
    
    UIView *bgView = kView;
    [self addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.lineChartView.mas_bottom).offset(5);
        
        make.bottom.mas_offset(-10);
        if(self.isLandscape){
            make.centerX.mas_offset(0);
        }else{
            make.left.mas_offset(0);
            make.right.mas_offset(0);
        }
    }];
   
     
    __block UIView *lastView;
    __block CGFloat margin = 10;
    __block CGFloat itemW = (kUI_WINDOW_W-30)/3;
    NSArray *titles = @[@"最高单体电压".rh_localized,@"最低单体电压".rh_localized,@"最大压差".rh_localized,@"最高电压位置".rh_localized,@"最低电压位置".rh_localized];
    [titles enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        UIView *itemView = [weakSelf itemViewWithIndex:idx title:titles[idx]];
        [bgView addSubview:itemView];
        if(idx == 0){
            [itemView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.top.mas_offset(0);
                make.width.offset(itemW);
                make.height.offset(itemW*0.6);
            }];
            //
        }else{
            if(idx%3==0 && !self.isLandscape){//换行
                [itemView mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.mas_offset(0);
                    make.top.equalTo(lastView.mas_bottom);
                    make.size.equalTo(lastView);
                }];
            }else{
                [itemView mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(lastView.mas_right);
                    make.centerY.equalTo(lastView);
                    make.size.equalTo(lastView);
                }];
            }
        }
                
        lastView = itemView;
        
        //不是最后一行就加上一竖线
        if((idx % 3 != 2 && !self.isLandscape) || (idx != (titles.count -1))){
            UIView *line = kView;
            line.backgroundColor = kCOLOR_HEX(@"E7E7E7");
            [self addSubview:line];
            [line mas_makeConstraints:^(MASConstraintMaker *make) {
                make.height.equalTo(lastView).multipliedBy(0.5);
                make.width.offset(1);
                make.centerY.equalTo(lastView);
                make.right.equalTo(lastView);
            }];
        }

    }];
    //封底
    [lastView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_offset(0);
        if(weakSelf.isLandscape){
            make.right.mas_offset(0);
        }
       
    }];
    
   
}




-(UIView*)itemViewWithIndex:(NSInteger)idx title:(NSString*)title
{
    UIView *bgView = kView;
    QMUILabel *titleLab = [[QMUILabel alloc]init];
    titleLab.textAlignment = NSTextAlignmentCenter;
    titleLab.tag = 100 + idx;
    titleLab.text = title;
    titleLab.textColor = [UIColor colorWithHexString:@"3F4443" alpha:0.6];
    titleLab.numberOfLines = 3;
    titleLab.adjustsFontSizeToFitWidth = YES;
    titleLab.minimumScaleFactor = 0.8;
    titleLab.font = kSYSTEMFONT(12);
    [bgView addSubview:titleLab];
    
    QMUILabel *contentLab = [[QMUILabel alloc]init];
    contentLab.textAlignment = NSTextAlignmentCenter;
    contentLab.tag = 200 + idx;
    contentLab.text = @"--";
    contentLab.textColor = [UIColor colorWithHexString:@"3F4443" alpha:1];
    contentLab.font = kSYSTEMFONT(14);
    [bgView addSubview:contentLab];
    
    [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(5);
        make.right.mas_offset(-5);
        make.centerY.mas_offset(15);
    }];
    
    [contentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(titleLab);
        make.centerY.mas_offset(-15);
    }];
    return bgView;
}




- (void)setChartModel:(RHCellRealDataModel *)chartModel{
   
    _chartModel = chartModel;
    [self setChartData];
    [self updateItemView];
    
}

#pragma mark ---- 设置曲线数据 ------
-(void)setChartData
{
    [self.lineChartView clear];
    self.leftUnitLab.hidden = YES;
    NSInteger labelCount = 10;
    //横屏显示多几个
    if(self.isLandscape){
        labelCount = 12;
    }

    [self.lineChartView.xAxis setLabelCount:labelCount force:YES];//设置x轴显示的个数

    //将 LineChartDataSet 对象放入数组中
    NSMutableArray *dataSets = [[NSMutableArray alloc] init];
    
    LineChartDataSet *set = [self createDataSetWithModel:self.chartModel linecolor:self.chartModel.color];
    set.axisDependency = AxisDependencyLeft;
    [dataSets addObject:set];
    //单位
    self.leftUnitLab.text = self.chartModel.unit;
    self.leftUnitLab.hidden = NO;
    
    self.lineChartView.leftAxis.axisMaximum = self.chartModel.maxValue+0.00001;
    self.lineChartView.leftAxis.axisMinimum = self.chartModel.minValue;
    //创建 LineChartData 对象, 此对象就是lineChartView需要最终数据对象
    LineChartData *lineData = [[LineChartData alloc] initWithDataSets:dataSets];
    self.lineChartView.data = lineData;
    //这里可以调用一个加载动画即1s出来一个绘制点
//    [self.lineChartView animateWithXAxisDuration:0.2f];
    //通知data去更新
    [self.lineChartView.data notifyDataChanged];
    //通知图表去更新
    [self.lineChartView notifyDataSetChanged];
    
    //点亮高亮图标
    if(self.chartModel.max_position>=0 && set.entries.count>1){
        NSLog(@"--->最大值的位置:%d",self.chartModel.max_position);
        NSLog(@"--->最小值的位置:%d",self.chartModel.min_position);
        
        ChartDataEntry *max_entry = set.entries[self.chartModel.max_position];
        ChartDataEntry *min_entry = set.entries[self.chartModel.min_position];
        
        CGPoint maxpoint = [self.lineChartView getPositionWithEntry:max_entry axis:AxisDependencyLeft];
        NSLog(@"----->maxpoint:%@",NSStringFromCGPoint(maxpoint));
        
        ChartHighlight *highlight_max = [[ChartHighlight alloc]initWithX:self.chartModel.max_position+1 y:max_entry.y dataSetIndex:0 dataIndex:self.chartModel.max_position];
        
        
        ChartHighlight *highlight_min = [[ChartHighlight alloc]initWithX:self.chartModel.min_position+1 y:min_entry.y dataSetIndex:0 dataIndex:self.chartModel.min_position];
        //点亮最大值和最小值
        self.maskView.chartModel = self.chartModel;
        [self.lineChartView highlightValues:@[highlight_max,highlight_min]];
    
        [self.lineChartView drawMarkers];
       
    }
   
   
}

#pragma mark ----- 创建曲线
-(LineChartDataSet*)createDataSetWithModel:(RHCellRealDataModel*)model linecolor:(NSString*)colorStr;
{
    NSMutableArray *entryArr = [[NSMutableArray alloc]init];
    
    [self.chartModel.xValues enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        ChartDataEntry *entry = [[ChartDataEntry alloc] initWithX:idx+1 y:[model.yValues[idx] floatValue]];
        [entryArr addObject:entry];
    }];
    
    
    LineChartDataSet *set = [[LineChartDataSet alloc] initWithEntries:entryArr label:@""];
    [set setColor:kCOLOR_HEX(colorStr)];//折线颜色
    //set1.lineDashLengths = @[@4.0,@2.0];//设置虚线各段长度
    set.mode = LineChartModeLinear;//曲线平滑显示   贝塞尔曲线
    
    set.drawIconsEnabled = YES;//是否绘制图标
    set.formLineWidth = 1.1;//图例的线宽
    set.formSize = 8.0;//图例的字体大小
    set.lineWidth = 2.0;//折线的宽度
    

    set.drawCirclesEnabled = NO;//是否绘制拐点
    set.drawCircleHoleEnabled = YES;//是否画空心圆
    set.circleColors = @[kCOLOR_HEX(colorStr)];//外圆颜色
    set.circleHoleColor = UIColor.whiteColor; //内圆颜色
    set.circleRadius = 2; //外圆半径
    set.circleHoleRadius = 1; //内圆半径
    
    set.drawValuesEnabled = NO;//是否在拐点处显示数据
    set.valueColors = @[kCOLOR_HEX(colorStr)];//拐点上的文字颜色
    set.valueFont = [UIFont systemFontOfSize:8];//拐点上的文字大小
    
    //折线拐点样式
    //第二种填充样式:渐变填充
    set.drawFilledEnabled = YES;//是否填充颜色
    NSArray *gradientColors = @[(id)[UIColor colorWithHexString:colorStr alpha:0.5].CGColor,
                                (id)[UIColor colorWithHexString:colorStr alpha:0.1].CGColor];
    CGGradientRef gradientRef = CGGradientCreateWithColors(nil, (CFArrayRef)gradientColors, nil);
    set.fillAlpha = 1.0f;//透明度
    set.fill = [[ChartLinearGradientFill alloc]initWithGradient:gradientRef angle:-90.0f];//赋值填充颜色对象
    CGGradientRelease(gradientRef);//释放gradientRef
    
    //点击选中拐点的交互样式
    set.highlightEnabled = YES;//选中拐点,是否开启高亮效果(显示十字线)
    set.drawVerticalHighlightIndicatorEnabled = NO; //不显示纵向十字线
    set.drawHorizontalHighlightIndicatorEnabled = NO; //不显示横向十字线
    set.highlightColor = kRGB(23,23,23);//点击选中拐点的十字线的颜色
    set.highlightLineWidth = 1.1/[UIScreen mainScreen].scale;//十字线宽度
    set.highlightLineDashLengths = @[@5, @5];//十字线的虚线样式
    
    return set;
}

-(void)updateItemView
{
    NSArray *titles = @[@"最高电压".rh_localized,@"最低电压".rh_localized,@"最大压差".rh_localized,@"最高电压位置".rh_localized,@"最低电压位置".rh_localized];
    NSArray *uintArr = @[@"V",@"V",@"V",@"",@""];
    if([self.chartModel.sectionTitle isEqualToString:@"温度统计".rh_localized]){
        titles = @[@"最高温度".rh_localized,@"最低温度".rh_localized,@"最大温差".rh_localized,@"最高温度位置".rh_localized,@"最低温度位置".rh_localized];
        uintArr = @[@"℃",@"℃",@"℃",@"",@""];
    }
    kWeakSelf;
    [titles enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        QMUILabel *titleLab = [weakSelf viewWithTag:100 + idx];
        QMUILabel *contentLab = [weakSelf viewWithTag:200 + idx];
        titleLab.text   = titles[idx];
        contentLab.text = [NSString stringWithFormat:@"%@%@",self.chartModel.pointDataArr[idx],uintArr[idx]];
    }];
    
}



- (LineChartView *)lineChartView{
    if (!_lineChartView) {
        _lineChartView = [[LineChartView alloc] initWithFrame:CGRectMake(0, 0,self.frame.size.width-10,self.frame.size.height-155)];
        
        _lineChartView.delegate = self;
        
        _lineChartView.chartDescription.enabled = NO;  //是否显示描述label
//        _lineChartView.extraRightOffset = 40;//右边缩进
        _lineChartView.extraBottomOffset = 10;//图表底部缩进,也就是与图例的距离
        _lineChartView.backgroundColor = kRGB(255, 255, 255);

        _lineChartView.noDataText = @"no data...";//没有数据时显示的文字
       
        _lineChartView.legend.enabled = NO;//是否显示说明图标
        _lineChartView.legend.form = ChartLegendFormSquare;//说明图例的样式  --指导价走势
        _lineChartView.legend.formSize = 3;//图例大小（头部）
        _lineChartView.legend.formToTextSpace = 5;//图例与文字的距离
        _lineChartView.legend.yOffset = 10;//图例与底部的距离
        _lineChartView.legend.xEntrySpace = 20;//图例与图例之间的距离
        _lineChartView.legend.neededHeight = 50;
        _lineChartView.legend.stackSpace = 10;
        _lineChartView.dragEnabled = YES; //拖动手势
        _lineChartView.dragDecelerationEnabled = YES;//拖拽后是否有惯性效果
        _lineChartView.dragDecelerationFrictionCoef = 0.9;//拖拽后惯性效果的摩擦系数(0~1)，数值越小，惯性越不明显
        _lineChartView.pinchZoomEnabled = YES; //捏合手势
        _lineChartView.rightAxis.enabled = NO;  //隐藏右Y轴
        _lineChartView.doubleTapToZoomEnabled = NO;  //禁止双击缩放
        _lineChartView.drawGridBackgroundEnabled = NO; //绘制图形区域背景
        _lineChartView.drawBordersEnabled = NO; //绘制图形区域边框
        _lineChartView.scaleYEnabled = NO;//Y轴不允许缩放
        _lineChartView.highlightPerTapEnabled = NO;//高亮点击
        _lineChartView.highlightPerDragEnabled = NO;//高亮拖拽
//        [_lineChartView setVisibleXRangeMaximum:8];// 最大显示区域
//        [_lineChartView setVisibleXRangeMinimum:2];// 最小显示区域
        
        
        _lineChartView.drawMarkers = YES;
        //气泡标签
//        ChartMarkerView *marker = [[ChartMarkerView alloc]
//                                 init];
//        marker.offset = CGPointZero;
//        marker.chartView = _lineChartView;
//        marker.minimumSize = CGSizeMake(60.f, 20.f);
//        marker.image = [UIImage imageNamed:@""];
        
        RHCellMarkerView *maskView = [[RHCellMarkerView alloc] initWithFrame:CGRectMake(0, 0, 40, 40*1.15)];
        maskView.chartView = _lineChartView;
//        [marker addSubview:maskView];
        self.maskView = maskView;
        _lineChartView.marker = maskView;
    
       
        //只滑动不缩放
    //    ChartViewPortHandler *scalX = self.LineChartView.viewPortHandler;
    //    [scalX setMinimumScaleX:1.01];
        
        
        //设置 左<--Y轴
        ChartYAxis *leftAxis =_lineChartView.leftAxis;
        leftAxis.labelPosition = YAxisLabelPositionOutsideChart;//label位置
        leftAxis.axisLineWidth = 1;
        leftAxis.axisMaxLabels = 6;     //y轴展示多少个
        leftAxis.axisMinLabels = 6;
        [leftAxis setLabelCount:6 force:YES];
        leftAxis.labelFont = [UIFont systemFontOfSize:12];
        leftAxis.labelTextColor = UIColor.lightGrayColor; //文本颜色
        leftAxis.axisLineColor = kRGB(217, 217, 217);    //左Y轴线条颜色
        leftAxis.gridLineDashLengths = @[@3.0f, @3.0f];//设置虚线样式的网格线
        leftAxis.gridColor = [UIColor colorWithRed:200/255.0f green:200/255.0f blue:200/255.0f alpha:1];//网格线颜色
        leftAxis.gridAntialiasEnabled = YES;//开启抗锯齿
        leftAxis.zeroLineColor = [UIColor redColor];    //左Y轴底线条颜色
        leftAxis.drawZeroLineEnabled = NO;//绘制0线
//        leftAxis.valueFormatter = [[RHLeftAxisFormatter alloc]initWithUnitArr:self.unitArr];
        leftAxis.valueFormatter = self;
        leftAxis.axisMinimum = 0;//Y轴最小值
        leftAxis.axisMaximum = 100;   //Y轴最大值
        
        
        //设置 右-->Y轴
        ChartYAxis *rightAxis =_lineChartView.rightAxis;
        rightAxis.labelPosition = YAxisLabelPositionOutsideChart;//label位置
        rightAxis.axisLineWidth = 1;
        rightAxis.axisMaxLabels = 6;     //y轴展示多少个
        [rightAxis setLabelCount:6 force:YES];
        rightAxis.labelFont = [UIFont systemFontOfSize:12];
        rightAxis.labelTextColor = UIColor.lightGrayColor; //文本颜色
        rightAxis.axisLineColor = kRGB(217, 217, 217);    //左Y轴线条颜色
        rightAxis.gridLineDashLengths = @[@3.0f, @3.0f];//设置虚线样式的网格线
        rightAxis.gridColor = [UIColor colorWithRed:200/255.0f green:200/255.0f blue:200/255.0f alpha:1];//网格线颜色
        rightAxis.gridAntialiasEnabled = YES;//开启抗锯齿
        rightAxis.zeroLineColor = [UIColor redColor];    //左Y轴底线条颜色
        rightAxis.drawZeroLineEnabled = NO;//绘制0线
        rightAxis.valueFormatter = self;
        rightAxis.axisMinimum = 0;//Y轴最小值
        rightAxis.axisMaximum = 1;   //Y轴最大值
        rightAxis.drawAxisLineEnabled = NO;
        rightAxis.valueFormatter = self;

        
        // 设置X轴
        ChartXAxis *xAxis =_lineChartView.xAxis;
        xAxis.axisLineWidth = 1.0/[UIScreen mainScreen].scale;//设置X轴线宽
        xAxis.axisLineColor = UIColor.lightGrayColor;
        xAxis.labelPosition =XAxisLabelPositionBottom; //x轴文字的位置
        xAxis.labelFont = [UIFont systemFontOfSize:12];//文字字体
        xAxis.labelTextColor = UIColor.lightGrayColor;//文字颜色
        xAxis.labelCount = 6;
        xAxis.axisMaxLabels = 15;//x轴最多显示个数;
        xAxis.axisMinLabels = 1;//x轴最少显示个数;
        xAxis.granularity = 1;//x轴标题中间最小的间隔。
        xAxis.drawAxisLineEnabled = YES;//是否画x轴线
//        xAxis.granularityEnabled = YES;//设备重复不显示
//        xAxis.forceLabelsEnabled = NO; //数据点强制显示个数
//        xAxis.avoidFirstLastClippingEnabled = YES;//避免文字显示不全 这个属性很重要

        
        xAxis.drawGridLinesEnabled = NO;//是否画网格
        xAxis.gridColor = UIColor.redColor;//x轴对应网格线的颜色
        xAxis.gridLineWidth = 1;//x轴对应网格线的大小
        xAxis.gridLineDashLengths = @[@4,@2];  //虚线各段长度
    //    xAxis.labelRotationAngle = -30.0;//设置文字旋转角度
       

        //自定义数据显示格式
    //     NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
    //    [formatter setNumberStyle:NSNumberFormatterDecimalStyle];
    //    [formatter setPositiveFormat:@"#0.0"];
    //    formatter.positivePrefix = @"#";
    //    xAxis.valueFormatter = [[ChartDefaultAxisValueFormatter alloc]initWithFormatter:formatter];
        xAxis.valueFormatter = self;

        //加载动画时长
//        [_lineChartView animateWithYAxisDuration:0.2 easingOption:ChartEasingOptionEaseInBack];
    }
    return _lineChartView;
}

#pragma mark --------------------chartView delegate ------------------
-(NSString *)stringForValue:(double)value axis:(ChartAxisBase *)axis
{
    //Y轴
    if ([axis isEqual:self.lineChartView.leftAxis]) {
        NSDecimalNumber *leftYValue = [NSDecimalNumber decimalNumberWithDouble:value];
        NSString *leftYValueString = [leftYValue decimalPlacesWithoutRoundDownWithDigit:3];
        return [NSDecimalNumber decimalStringWithDoubleString:leftYValueString nullStr:@"0"];
    }
    if ([axis isEqual:self.lineChartView.rightAxis]) {
        return @"--";
    }
    NSInteger index = (NSInteger)value;
    return  [self.chartModel.xValues safeObjectAtIndex:index];
}

#pragma mark 图表中数值被选中
-(void)chartValueSelected:(ChartViewBase *)chartView entry:(ChartDataEntry *)entry highlight:(ChartHighlight *)highlight{
    
//    [self.maskView updateModel:self.chartModel index:(NSInteger)highlight.x colors:self.colorList];

    ChartMarkerView *makerView = (ChartMarkerView*)chartView.marker;
    CGFloat off_x = 0;
    if(chartView.width - highlight.xPx < self.maskView.width)
    {
        off_x = -self.maskView.width;
    }else if (highlight.xPx < self.maskView.width/2){
        off_x = 0;
    }else{
        off_x = -self.maskView.width/2;
    }

    makerView.offset = CGPointMake(off_x, -self.maskView.height/2);
    
//    NSLog(@"----->chartView.maskView frame:%@",NSStringFromCGRect(chartView.maskView.frame)) ;
//    NSLog(@"----->self.maskView frame:%@",NSStringFromCGRect(self.maskView.frame)) ;
//    NSLog(@"------>entry.x=%f",entry.x);
//    NSLog(@"------>entry.y=%f",entry.y);
//    NSLog(@"------>highlight.x=%f",highlight.x);
    NSLog(@"------>highlight.xPx=%f",highlight.xPx);
//    NSLog(@"------>highlight.drawX=%f",highlight.drawX);
//    NSLog(@"------>highlight.y=%f",highlight.y);
//    NSLog(@"------>highlight.yPx=%f",highlight.yPx);
//    NSLog(@"------>highlight.drawY=%f",highlight.drawY);
//    NSLog(@"------>highlight.xPx=%f",chartView.xAxis.);
    NSLog(@"------>label_width=%f",chartView.xAxis.labelWidth);
       
    
    
}

#pragma mark 图表中的空白区域被选中
-(void)chartValueNothingSelected:(ChartViewBase *)chartView{
    NSLog(@"空白区域被选中");
}

#pragma mark 图表被缩放
-(void)chartScaled:(ChartViewBase *)chartView scaleX:(CGFloat)scaleX scaleY:(CGFloat)scaleY{

    
}

#pragma mark 图表被移动
-(void)chartTranslated:(ChartViewBase *)chartView dX:(CGFloat)dX dY:(CGFloat)dY{
//    NSLog(@"图表被移动");
}



#pragma mark ------ lazy load

- (NSMutableArray *)itemsArray{
    if (!_itemsArray) {
        _itemsArray = [NSMutableArray array];
    }
    return _itemsArray;
}
-(NSMutableArray *)unitArr
{
    if(!_unitArr)
    {
        _unitArr = [NSMutableArray array];
    }
    return _unitArr;;
}
-(NSMutableArray *)pointViewArr
{
    if(!_pointViewArr)
    {
        _pointViewArr = [NSMutableArray array];
    }
    return _pointViewArr;;
}

@end
